nl.justobjects.pushlet.client
Class PushletClient

java.lang.Object
  extended by nl.justobjects.pushlet.client.PushletClient
All Implemented Interfaces:
Protocol

public class PushletClient
extends java.lang.Object
implements Protocol

Client API for Java HTTP client applets or apps.

Use this class within Java client applications or applets. Implement a PushletClientListener to receive callbacks for data-related Event objects pushed by the server.

This class may also be used as a base class and be extended for custom clients, hence the presence of many proteced methods.

Version:
$Id: PushletClient.java,v 1.19 2009/06/04 12:46:35 justb Exp $
Author:
Just van den Broecke - Just Objects ©
See Also:
PushletClientListener, nl.justobjects.pushlet.test.PushletApplet, nl.justobjects.pushlet.test.PushletPingApplication

Field Summary
 
Fields inherited from interface nl.justobjects.pushlet.core.Protocol
DEFAULT_SERVLET_URI, E_ABORT, E_DATA, E_HEARTBEAT, E_HEARTBEAT_ACK, E_JOIN, E_JOIN_ACK, E_JOIN_LISTEN, E_JOIN_LISTEN_ACK, E_LEAVE, E_LEAVE_ACK, E_LISTEN, E_LISTEN_ACK, E_NACK, E_PUBLISH, E_PUBLISH_ACK, E_REFRESH, E_REFRESH_ACK, E_SUBSCRIBE, E_SUBSCRIBE_ACK, E_UNSUBSCRIBE, E_UNSUBSCRIBE_ACK, FORMAT_JAVASCRIPT, FORMAT_SERIALIZED_JAVA_OBJECT, FORMAT_XML, FORMAT_XML_STRICT, MODE_POLL, MODE_PULL, MODE_STREAM, P_EVENT, P_FORMAT, P_FROM, P_ID, P_MODE, P_REASON, P_SEQ, P_SUBJECT, P_SUBSCRIPTION_ID, P_SUBSCRIPTION_LABEL, P_TIME, P_TO, P_URL, P_WAIT, SUBJECT_META, SUBJECT_META_JOINS, SUBJECT_META_SUBS
 
Constructor Summary
PushletClient(java.lang.String aPushletURL)
          Constructor with full pushlet URL.
PushletClient(java.lang.String aHost, int aPort)
          Constructor with host and port using default URI.
 
Method Summary
 void join()
          Join server, starts session.
 void joinListen(PushletClientListener aListener, java.lang.String aMode, java.lang.String aSubject)
          Immediate listener: joins/subscribes and listens in one action.
 void leave()
          Leave server, stops session.
 void listen(PushletClientListener aListener)
          Open data channel.
 void listen(PushletClientListener aListener, java.lang.String aMode)
          Open data channel in stream or push mode.
 void listen(PushletClientListener aListener, java.lang.String aMode, java.lang.String aSubject)
          Open data channel in stream or push mode with a subject.
 void publish(java.lang.String aSubject, java.util.Map theAttributes)
          Publish an event through server.
 void setDebug(boolean b)
           
 void setProxyOptions(java.lang.String aProxyHost, java.lang.String aProxyPort, java.lang.String theNonProxyHosts, java.lang.String aUserName, java.lang.String aPassword, java.lang.String anNTLMDomain)
          Set proxy options and optional proxy authentication.
 void stopListen()
          Stop the listener.
 java.lang.String subscribe(java.lang.String aSubject)
          Subscribes, returning subscription id.
 java.lang.String subscribe(java.lang.String aSubject, java.lang.String aLabel)
          Subscribes, returning subscription id.
 void unsubscribe()
          Unsubscribes from all subjects.
 void unsubscribe(java.lang.String aSubscriptionId)
          Unsubscribes with subscription id.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushletClient

public PushletClient(java.lang.String aPushletURL)
Constructor with full pushlet URL.


PushletClient

public PushletClient(java.lang.String aHost,
                     int aPort)
Constructor with host and port using default URI.

Method Detail

setProxyOptions

public void setProxyOptions(java.lang.String aProxyHost,
                            java.lang.String aProxyPort,
                            java.lang.String theNonProxyHosts,
                            java.lang.String aUserName,
                            java.lang.String aPassword,
                            java.lang.String anNTLMDomain)
Set proxy options and optional proxy authentication.

Contributed by Dele Olajide See http://groups.yahoo.com/group/pushlet/message/634

Usage: PushletClient pushletClient = new PushletClient("http:://www.domain.com/pushlet"); pushletClient.setProxyOptions("proxy.bla.com", "8080", ....);

use pushletClient further as normal


join

public void join()
          throws PushletException
Join server, starts session.

Throws:
PushletException

leave

public void leave()
           throws PushletException
Leave server, stops session.

Throws:
PushletException

listen

public void listen(PushletClientListener aListener)
            throws PushletException
Open data channel.

Throws:
PushletException

listen

public void listen(PushletClientListener aListener,
                   java.lang.String aMode)
            throws PushletException
Open data channel in stream or push mode.

Throws:
PushletException

listen

public void listen(PushletClientListener aListener,
                   java.lang.String aMode,
                   java.lang.String aSubject)
            throws PushletException
Open data channel in stream or push mode with a subject.

Throws:
PushletException

joinListen

public void joinListen(PushletClientListener aListener,
                       java.lang.String aMode,
                       java.lang.String aSubject)
                throws PushletException
Immediate listener: joins/subscribes and listens in one action.

Throws:
PushletException

publish

public void publish(java.lang.String aSubject,
                    java.util.Map theAttributes)
             throws PushletException
Publish an event through server.

Throws:
PushletException

subscribe

public java.lang.String subscribe(java.lang.String aSubject,
                                  java.lang.String aLabel)
                           throws PushletException
Subscribes, returning subscription id.

Throws:
PushletException

subscribe

public java.lang.String subscribe(java.lang.String aSubject)
                           throws PushletException
Subscribes, returning subscription id.

Throws:
PushletException

unsubscribe

public void unsubscribe(java.lang.String aSubscriptionId)
                 throws PushletException
Unsubscribes with subscription id.

Throws:
PushletException

unsubscribe

public void unsubscribe()
                 throws PushletException
Unsubscribes from all subjects.

Throws:
PushletException

stopListen

public void stopListen()
                throws PushletException
Stop the listener.

Throws:
PushletException

setDebug

public void setDebug(boolean b)